package com.final_project.zombiemenace.model;

import java.util.List;

import com.kilobolt.framework.Game;
import com.kilobolt.framework.Image;

public class TempImage {

	private static final int MINIMUM_IMAGE_LIFE = 1;
	private static final int IMAGE_DURATION_ON_SCREEN = 250;
	private int x;
	private int y;
	private Image img;
	private int imageDuration = IMAGE_DURATION_ON_SCREEN;
	private List<TempImage> temps;

	public TempImage(List<TempImage> temps, Game game, float x,

	float y, Image img) {
		this.x = (int) Math.min(Math.max(x - img.getWidth() / 2, 0), game
				.getGraphics().getWidth() - img.getWidth());
		this.y = (int) Math.min(Math.max(y - img.getHeight() / 2, 0), game
				.getGraphics().getHeight() - img.getHeight());
		this.img = img;
		this.temps = temps;

	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public Image getImg() {
		return img;
	}

	public void update() {
		if (--imageDuration < MINIMUM_IMAGE_LIFE) {
			temps.remove(this);
		}
	}
}
